from enum import Enum, unique
_types = [
    ('1', 'Free or paid app ', 'iOS, iPadOS, visionOS, watchOS'),
    ('1-B', 'App Bundle', 'iOS, iPadOS, visionOS app bundle'),
    ('F1-B', 'App Bundle', 'Mac app bundle'),
    ('1E', 'Paid app', 'Custom iOS app'),
    ('1EP', 'Paid app', 'Custom iPadOS app'),
    ('1EU', 'Paid app', 'Custom universal app'),
    ('1F', 'Free or paid app ', 'Universal app, excluding tvOS'),
    ('1T', 'Free or paid app ', 'iPad apps'),
    ('3', 'Re-download', 'App update (iOS, tvOS, visionOS, watchOS)'),
    ('3F', 'Re-download', 'Universal app, excluding tvOS'),
    ('7', 'Update', 'App update (iOS, tvOS, visionOS, watchOS)'),
    ('7F', 'Update', 'Universal app, excluding tvOS'),
    ('7T', 'Update', 'App update (iPadOS, visionOS)'),
    ('F1', 'Free or paid app ', 'Mac'),
    ('F7', 'Update', 'App update (Mac)'),
    ('FI1', 'In-App Purchase', 'Mac'),
    ('IA1', 'In-App Purchase', 'In-app purchase (iOS, iPadOS, visionOS)'),
    ('IA1-M', 'In-App Purchase', 'In-app purchase (Mac)'),
    ('IA3', 'Restored In-App Purchase', 'Non consumable in-app purchase'),
    ('IA9', 'In-App Purchase', 'Non-renewing subscription (iOS, iPadOS, visionOS)'),
    ('IA9-M', 'In-App Purchase', 'Subscription (Mac)'),
    ('IAY', 'In-App Purchase', 'Auto-renewable subscription (iOS, iPadOS, visionOS)'),
    ('IAY-M', 'In-App Purchase', 'Auto-renewable subscription (Mac)'),
]

@unique
class ProductTypeIdentifier(Enum):
    free_or_paid_app_ios = '1'
    app_bundle_ios = '1-B'
    app_bundle_mac = 'F1-B'
    paid_app_custom_ios = '1E'
    paid_app_custom_ipados = '1EP'
    paid_app_custom_universal = '1EU'
    free_or_paid_app_universal = '1F'
    free_or_paid_app_ipad = '1T'
    re_download_app_update_ios = '3'
    re_download_universal_app = '3F'
    update_app_update_ios = '7'
    update_universal_app = '7F'
    update_app_update_ipados = '7T'
    free_or_paid_app_mac = 'F1'
    update_app_update_mac = 'F7'
    in_app_purchase_mac = 'FI1'
    in_app_purchase_ios = 'IA1'
    in_app_purchase_mac_2 = 'IA1-M'
    restored_in_app_purchase = 'IA3'
    non_renewing_subscription_ios = 'IA9'
    subscription_mac = 'IA9-M'
    subscription_auto_renewable_ios = 'IAY'
    subscription_auto_renewable_mac = 'IAY-M'
    
    @classmethod
    def is_new_install(cls, value):
        return value in [cls.free_or_paid_app_ios.value, cls.app_bundle_ios.value, cls.app_bundle_mac.value, cls.paid_app_custom_ios.value, cls.paid_app_custom_ipados.value, cls.paid_app_custom_universal.value, cls.free_or_paid_app_universal.value, cls.free_or_paid_app_ipad.value, cls.free_or_paid_app_mac.value]
    
    @classmethod
    def new_install_identifiers(cls):
        return [cls.free_or_paid_app_ios.value, cls.app_bundle_ios.value, cls.app_bundle_mac.value, cls.paid_app_custom_ios.value, cls.paid_app_custom_ipados.value, cls.paid_app_custom_universal.value, cls.free_or_paid_app_universal.value, cls.free_or_paid_app_ipad.value, cls.free_or_paid_app_mac.value] 

    @classmethod
    def is_in_app_purchase(cls, value):
        return value in [cls.in_app_purchase_ios.value, cls.in_app_purchase_mac.value, cls.in_app_purchase_mac_2.value, cls.restored_in_app_purchase.value, cls.non_renewing_subscription_ios.value, cls.subscription_mac.value, cls.subscription_auto_renewable_ios.value, cls.subscription_auto_renewable_mac.value]  
    
    @classmethod
    def is_subcription(cls, value):
        return value in [cls.non_renewing_subscription_ios.value, cls.subscription_mac.value, cls.subscription_auto_renewable_ios.value, cls.subscription_auto_renewable_mac.value] 
    
